package logic

import (
	"news/dao/mysql"
	"news/models"
)

//社区业务逻辑处理
func Community(p *models.Community) (err error) {
	// 判断社区名是否有重复
	err = mysql.CheckCommunityNameExit(p.CommunityName)
	if err != nil {
		return err
	}
	// 构造一个community的实例
	err = mysql.InsertCommunity(p)
	return
}

// 社区分类的编辑
func CommunityEdit(CommunityID int64) (communityCatList *models.Community, err error) {
	return mysql.CommunityEdit(CommunityID)
}

// 社区列表信息展示
func GetCommunityList() (communityList []*models.Community, err error) {
	return mysql.GetCommunityList()

}

//社区详情ID
func GetCommunityDetail(id int64) (community *models.Community, err error) {
	return mysql.GetCommunityDetailByID(id)
}
